package org.sirmupadbapi.persistencia;

import org.sirmupadbapi.beans.Regimenvehicles;
import java.sql.Date; 
import org.sirmupadbapi.beans.*;
import org.sirmupadbapi.controller.*;
import java.io.Serializable;
import java.util.List;
import java.util.ArrayList;
import java.util.*;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.util.Map;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
 import javax.sql.DataSource;
import org.sirmupadbapi.generales.Mensajeria;
import org.sirmupadbapi.generales.DataGManager;


/**
*
* @author
*/

public class RegimenvehiclesPersistencia implements Serializable {
private static final long serialVersionUID = 1L;
public static Exception excepcion;
public static boolean esMensaje = false;
public static Connection con = null;
public static java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/sirmupadbapi/properties/mensajes");
static DataGManager dataGManager;
static List<Regimenvehicles> list;

public RegimenvehiclesPersistencia(){
         esMensaje =false;
}


/**
*
* insert()
*/

public static boolean insert (Regimenvehicles regimenvehicles ) {
  excepcion = null;
  try {
      esMensaje =false;
   
   
   

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pinsert = null;
      String sql = "insert into regimenvehicles(IDVEHICULO,IDREGIMEN,VALOR,PERIODOPAGO,MESPAGO,FECHAINSCRIPCION,IDUSUARIO,FECHA,ACTIVO,IDMUNICIPIO)  values(?,?,?,?,?,?,?,?,?,?)";
      pinsert = con.prepareStatement(sql);
              pinsert.setLong(1,regimenvehicles.getIDVEHICULO());
        pinsert.setString(2,regimenvehicles.getIDREGIMEN());
        pinsert.setDouble(3,regimenvehicles.getVALOR());
        pinsert.setString(4,regimenvehicles.getPERIODOPAGO());
        pinsert.setString(5,regimenvehicles.getMESPAGO());
        pinsert.setDate(6,regimenvehicles.getFECHAINSCRIPCION());
        pinsert.setString(7,regimenvehicles.getIDUSUARIO());
        pinsert.setDate(8,regimenvehicles.getFECHA());
        pinsert.setString(9,regimenvehicles.getACTIVO());
        pinsert.setString(10,regimenvehicles.getIDMUNICIPIO());
      int filas= pinsert.executeUpdate();
      pinsert.close();
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
 }


/**
*
* update()
*/

public static boolean update(Regimenvehicles regimenvehicles ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update regimenvehicles set  IDVEHICULO=?, IDREGIMEN=?, VALOR=?, PERIODOPAGO=?, MESPAGO=?, FECHAINSCRIPCION=?, IDUSUARIO=?, FECHA=?, ACTIVO=?, IDMUNICIPIO=?  where  IDVEHICULO ='"+regimenvehicles.getIDVEHICULO()+"' and  IDREGIMEN ='"+regimenvehicles.getIDREGIMEN()+"' and  ACTIVO ='"+regimenvehicles.getACTIVO()+"' and  IDMUNICIPIO ='"+regimenvehicles.getIDMUNICIPIO()+"'  ";
      pupdate= con.prepareStatement(sql);
      pupdate.setLong(1,regimenvehicles.getIDVEHICULO());
pupdate.setString(2,regimenvehicles.getIDREGIMEN());
pupdate.setDouble(3,regimenvehicles.getVALOR());
pupdate.setString(4,regimenvehicles.getPERIODOPAGO());
pupdate.setString(5,regimenvehicles.getMESPAGO());
pupdate.setDate(6,regimenvehicles.getFECHAINSCRIPCION());
pupdate.setString(7,regimenvehicles.getIDUSUARIO());
pupdate.setDate(8,regimenvehicles.getFECHA());
pupdate.setString(9,regimenvehicles.getACTIVO());
pupdate.setString(10,regimenvehicles.getIDMUNICIPIO());
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* update()
*/

public static boolean update(String sqlupdate ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update  regimenvehicles set " + sqlupdate +"";
      pupdate= con.prepareStatement(sql);
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* updatePrimaryKey()
*/

public static boolean updatePrimaryKey(Regimenvehicles regimenvehicles_old , Regimenvehicles regimenvehicles) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update regimenvehicles set  IDVEHICULO=? ,  IDREGIMEN=? ,  ACTIVO=? ,  IDMUNICIPIO=?  where  IDVEHICULO ='"+regimenvehicles_old.getIDVEHICULO()+"' and  IDREGIMEN ='"+regimenvehicles_old.getIDREGIMEN()+"' and  ACTIVO ='"+regimenvehicles_old.getACTIVO()+"' and  IDMUNICIPIO ='"+regimenvehicles_old.getIDMUNICIPIO()+"'  ";
      pupdate= con.prepareStatement(sql);
      pupdate.setLong(1,regimenvehicles.getIDVEHICULO());pupdate.setString(2,regimenvehicles.getIDREGIMEN());pupdate.setString(9,regimenvehicles.getACTIVO());pupdate.setString(10,regimenvehicles.getIDMUNICIPIO());
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(Regimenvehicles regimenvehicles ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from regimenvehicles  where  IDVEHICULO = ? and  IDREGIMEN = ? and  ACTIVO = ? and  IDMUNICIPIO = ?  ";
      pdelete= con.prepareStatement(sql);
      pdelete.setLong(1,regimenvehicles.getIDVEHICULO());
pdelete.setString(2,regimenvehicles.getIDREGIMEN());
pdelete.setString(9,regimenvehicles.getACTIVO());
pdelete.setString(10,regimenvehicles.getIDMUNICIPIO());
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(String sqldelete ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from regimenvehicles where " + sqldelete +"";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* deleteAll()
*/

public static boolean deleteAll() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from regimenvehicles  ";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodeleteall"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* exists()
*/



public static boolean exists(Regimenvehicles regimenvehicles) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      String sql = "select * from regimenvehicles where IDVEHICULO='"+regimenvehicles.getIDVEHICULO()+"' and IDREGIMEN='"+regimenvehicles.getIDREGIMEN()+"' and ACTIVO='"+regimenvehicles.getACTIVO()+"' and IDMUNICIPIO='"+regimenvehicles.getIDMUNICIPIO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +" " + bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return false;
   }
    rs.close();
    psquery.close();
 return true;
} catch (Exception ex) {
      excepcion = ex;
}
  return false;
}


/**
*
* findByPrimaryKey()
*/



public static Regimenvehicles findByPrimaryKey(Regimenvehicles regimenvehicles) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
      String sql = "select * from regimenvehicles where IDVEHICULO='"+regimenvehicles.getIDVEHICULO()+"' and IDREGIMEN='"+regimenvehicles.getIDREGIMEN()+"' and ACTIVO='"+regimenvehicles.getACTIVO()+"' and IDMUNICIPIO='"+regimenvehicles.getIDMUNICIPIO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
            
            
            regimenvehicles.setIDVEHICULO(rs.getLong("IDVEHICULO"));
regimenvehicles.setIDREGIMEN(rs.getString("IDREGIMEN"));
regimenvehicles.setVALOR(rs.getDouble("VALOR"));
regimenvehicles.setPERIODOPAGO(rs.getString("PERIODOPAGO"));
regimenvehicles.setMESPAGO(rs.getString("MESPAGO"));
regimenvehicles.setFECHAINSCRIPCION(rs.getDate("FECHAINSCRIPCION"));
regimenvehicles.setIDUSUARIO(rs.getString("IDUSUARIO"));
regimenvehicles.setFECHA(rs.getDate("FECHA"));
regimenvehicles.setACTIVO(rs.getString("ACTIVO"));
regimenvehicles.setIDMUNICIPIO(rs.getString("IDMUNICIPIO"));
    }
    rs.close();
    psquery.close();
 return regimenvehicles;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDVEHICULO()
*/

public static List<Regimenvehicles> findByIDVEHICULO(Regimenvehicles regimenvehicles,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehicles>();
      String sql = "select * from regimenvehicles where IDVEHICULO='"+regimenvehicles.getIDVEHICULO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehicles regimenvehicles2 = new Regimenvehicles(
         rs.getLong("IDVEHICULO"),rs.getString("IDREGIMEN"),rs.getDouble("VALOR"),rs.getString("PERIODOPAGO"),rs.getString("MESPAGO"),rs.getDate("FECHAINSCRIPCION"),rs.getString("IDUSUARIO"),rs.getDate("FECHA"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"));
            
            
       list.add(regimenvehicles2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDREGIMEN()
*/

public static List<Regimenvehicles> findByIDREGIMEN(Regimenvehicles regimenvehicles,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehicles>();
      String sql = "select * from regimenvehicles where IDREGIMEN='"+regimenvehicles.getIDREGIMEN()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehicles regimenvehicles2 = new Regimenvehicles(
         rs.getLong("IDVEHICULO"),rs.getString("IDREGIMEN"),rs.getDouble("VALOR"),rs.getString("PERIODOPAGO"),rs.getString("MESPAGO"),rs.getDate("FECHAINSCRIPCION"),rs.getString("IDUSUARIO"),rs.getDate("FECHA"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"));
            
            
       list.add(regimenvehicles2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByVALOR()
*/

public static List<Regimenvehicles> findByVALOR(Regimenvehicles regimenvehicles,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehicles>();
      String sql = "select * from regimenvehicles where VALOR='"+regimenvehicles.getVALOR()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehicles regimenvehicles2 = new Regimenvehicles(
         rs.getLong("IDVEHICULO"),rs.getString("IDREGIMEN"),rs.getDouble("VALOR"),rs.getString("PERIODOPAGO"),rs.getString("MESPAGO"),rs.getDate("FECHAINSCRIPCION"),rs.getString("IDUSUARIO"),rs.getDate("FECHA"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"));
            
            
       list.add(regimenvehicles2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByPERIODOPAGO()
*/

public static List<Regimenvehicles> findByPERIODOPAGO(Regimenvehicles regimenvehicles,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehicles>();
      String sql = "select * from regimenvehicles where PERIODOPAGO='"+regimenvehicles.getPERIODOPAGO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehicles regimenvehicles2 = new Regimenvehicles(
         rs.getLong("IDVEHICULO"),rs.getString("IDREGIMEN"),rs.getDouble("VALOR"),rs.getString("PERIODOPAGO"),rs.getString("MESPAGO"),rs.getDate("FECHAINSCRIPCION"),rs.getString("IDUSUARIO"),rs.getDate("FECHA"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"));
            
            
       list.add(regimenvehicles2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByMESPAGO()
*/

public static List<Regimenvehicles> findByMESPAGO(Regimenvehicles regimenvehicles,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehicles>();
      String sql = "select * from regimenvehicles where MESPAGO='"+regimenvehicles.getMESPAGO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehicles regimenvehicles2 = new Regimenvehicles(
         rs.getLong("IDVEHICULO"),rs.getString("IDREGIMEN"),rs.getDouble("VALOR"),rs.getString("PERIODOPAGO"),rs.getString("MESPAGO"),rs.getDate("FECHAINSCRIPCION"),rs.getString("IDUSUARIO"),rs.getDate("FECHA"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"));
            
            
       list.add(regimenvehicles2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFECHAINSCRIPCION()
*/

public static List<Regimenvehicles> findByFECHAINSCRIPCION(Regimenvehicles regimenvehicles,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehicles>();
      String sql = "select * from regimenvehicles where FECHAINSCRIPCION='"+regimenvehicles.getFECHAINSCRIPCION()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehicles regimenvehicles2 = new Regimenvehicles(
         rs.getLong("IDVEHICULO"),rs.getString("IDREGIMEN"),rs.getDouble("VALOR"),rs.getString("PERIODOPAGO"),rs.getString("MESPAGO"),rs.getDate("FECHAINSCRIPCION"),rs.getString("IDUSUARIO"),rs.getDate("FECHA"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"));
            
            
       list.add(regimenvehicles2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDUSUARIO()
*/

public static List<Regimenvehicles> findByIDUSUARIO(Regimenvehicles regimenvehicles,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehicles>();
      String sql = "select * from regimenvehicles where IDUSUARIO='"+regimenvehicles.getIDUSUARIO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehicles regimenvehicles2 = new Regimenvehicles(
         rs.getLong("IDVEHICULO"),rs.getString("IDREGIMEN"),rs.getDouble("VALOR"),rs.getString("PERIODOPAGO"),rs.getString("MESPAGO"),rs.getDate("FECHAINSCRIPCION"),rs.getString("IDUSUARIO"),rs.getDate("FECHA"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"));
            
            
       list.add(regimenvehicles2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFECHA()
*/

public static List<Regimenvehicles> findByFECHA(Regimenvehicles regimenvehicles,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehicles>();
      String sql = "select * from regimenvehicles where FECHA='"+regimenvehicles.getFECHA()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehicles regimenvehicles2 = new Regimenvehicles(
         rs.getLong("IDVEHICULO"),rs.getString("IDREGIMEN"),rs.getDouble("VALOR"),rs.getString("PERIODOPAGO"),rs.getString("MESPAGO"),rs.getDate("FECHAINSCRIPCION"),rs.getString("IDUSUARIO"),rs.getDate("FECHA"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"));
            
            
       list.add(regimenvehicles2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByACTIVO()
*/

public static List<Regimenvehicles> findByACTIVO(Regimenvehicles regimenvehicles,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehicles>();
      String sql = "select * from regimenvehicles where ACTIVO='"+regimenvehicles.getACTIVO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehicles regimenvehicles2 = new Regimenvehicles(
         rs.getLong("IDVEHICULO"),rs.getString("IDREGIMEN"),rs.getDouble("VALOR"),rs.getString("PERIODOPAGO"),rs.getString("MESPAGO"),rs.getDate("FECHAINSCRIPCION"),rs.getString("IDUSUARIO"),rs.getDate("FECHA"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"));
            
            
       list.add(regimenvehicles2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDMUNICIPIO()
*/

public static List<Regimenvehicles> findByIDMUNICIPIO(Regimenvehicles regimenvehicles,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehicles>();
      String sql = "select * from regimenvehicles where IDMUNICIPIO='"+regimenvehicles.getIDMUNICIPIO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehicles regimenvehicles2 = new Regimenvehicles(
         rs.getLong("IDVEHICULO"),rs.getString("IDREGIMEN"),rs.getDouble("VALOR"),rs.getString("PERIODOPAGO"),rs.getString("MESPAGO"),rs.getDate("FECHAINSCRIPCION"),rs.getString("IDUSUARIO"),rs.getDate("FECHA"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"));
            
            
       list.add(regimenvehicles2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* locateByParameters()
*/

public static List<Regimenvehicles> locateByParameters(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehicles>();
  String sql = "select * from regimenvehicles";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      int i = 0;
      while (it.hasNext()) {
          if (i != 0){
            sb.append(" and ");
         }
         i++;
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"= '"+  e.getValue()+"'");
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehicles regimenvehicles2 = new Regimenvehicles(
         rs.getLong("IDVEHICULO"),rs.getString("IDREGIMEN"),rs.getDouble("VALOR"),rs.getString("PERIODOPAGO"),rs.getString("MESPAGO"),rs.getDate("FECHAINSCRIPCION"),rs.getString("IDUSUARIO"),rs.getDate("FECHA"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"));
            
            
       list.add(regimenvehicles2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* Double fFunc(String funcion, String campo)
*/



public static Double func(String funcion, String campo) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from regimenvehicles";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0.0;
}


/**
*
* Double func(String funcion, String campo,String where)
*/



public static Double func(String funcion, String campo, String where) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from regimenvehicles where "+where +" ";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0.0;
}


/**
*
* count()
*/



public static Integer count() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from regimenvehicles";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
   rs.beforeFirst();
   while (rs.next()) {
    x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0;
}


/**
*
* count(String sqlquery)
*/



public static Integer count(String sqlquery) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from regimenvehicles where  " + sqlquery +"";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
   rs.beforeFirst();
   while (rs.next()) {
    x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0;
}


/**
*
* query()
*/

public static List<Regimenvehicles> query(String query,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<Regimenvehicles>();
  String sql = "select * from regimenvehicles where " + query +"";
  if (query == null || query.equals("")) {
  return null;
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehicles regimenvehicles2 = new Regimenvehicles(
         rs.getLong("IDVEHICULO"),rs.getString("IDREGIMEN"),rs.getDouble("VALOR"),rs.getString("PERIODOPAGO"),rs.getString("MESPAGO"),rs.getDate("FECHAINSCRIPCION"),rs.getString("IDUSUARIO"),rs.getDate("FECHA"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"));
            
            
       list.add(regimenvehicles2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* getListRecords()
*/

public static List<Regimenvehicles> getListRecords(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
      list = new ArrayList<Regimenvehicles>();
  String sql = "select * from regimenvehicles";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"="+  e.getValue());
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehicles" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
       
        Regimenvehicles regimenvehicles2 = new Regimenvehicles(
         rs.getLong("IDVEHICULO"),rs.getString("IDREGIMEN"),rs.getDouble("VALOR"),rs.getString("PERIODOPAGO"),rs.getString("MESPAGO"),rs.getDate("FECHAINSCRIPCION"),rs.getString("IDUSUARIO"),rs.getDate("FECHA"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"));
            
            
       list.add(regimenvehicles2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
 }


}
